<?php

namespace App\Http\Controllers\Common;

use App\Http\Controllers\BaseController;
use App\Models\Custom\Config;
use Illuminate\Http\Request;

class ConfigController extends BaseController
{

    public function getconfig(Request $request)
    {
        $cpid = $this->mangerinfo['cpid'];
        $config_key=strval($request->config_key);
        if($config_key==''){
            return response()->json(['code' => '001', 'msg' => '无效参数']);
        }
        $config_val = Config::getConfig($cpid, $config_key);
        return response()->json(['code' => '000', 'msg' => '操作成功', 'data' => ['config_val'=>$config_val]]);
    }


    public function setconfig(Request $request)
    {
        $cpid = $this->mangerinfo['cpid'];
        $config_key=strval($request->config_key);
        $config_val=strval($request->config_val);
        if($config_key==''){
            return response()->json(['code' => '001', 'msg' => '无效参数']);
        }



         Config::setConfig($cpid, $config_key,$config_val);
        return response()->json(['code' => '000', 'msg' => '操作成功']);
    }
}